#@tabLayout()

#define main()
<div style="">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 课程管理 <span class="c-gray en">&gt;</span> 课程列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">
		#if(role == 3)
		<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><!--<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>--> <a class="btn btn-primary radius" onclick="course_add('添加课程','#(baseUrl)/course/addPage')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加课程</a></span></div>
		#end
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort" id="course-table">
				<thead>
					<tr class="text-c">
						<th>课程编号</th>
						<th>课程名称</th>
						<th>任课教师</th>
						<th>学分</th>
						<th>课时</th>
						<th>操作</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
#end

#define js()
<script type="text/javascript">

var course_table = $('#course-table').DataTable({
	"processing": true,
	"serverSide": true,
	"ajax":"#(baseUrl)/course/list",
	"columns": [
		{"data":"Course_ID",},
		{"data":"Course_name"},
		{"data":"Teacher_name"},
		{"data":"Credit"},
		{"data":"Course_hour"},
		{
			"data":null,
			"render":function(data, type, full ,meta){
				var btn = #if(role == 3)
						  '<a style="text-decoration:none" class="ml-5" onClick="course_del(this,\''+full.Course_ID+'\')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>'+
				   		  '<a style="text-decoration:none" class="ml-5" onClick="course_edit(this,\''+full.Course_ID+'\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>';
						  #elseif(role == 1)
						  '<a style="text-decoration:none" class="ml-5" onClick="course_select(\''+full.Course_ID+'\')" href="javascript:;" title="选课"><i class="Hui-iconfont">&#xe600;</i>选课</a>';
						  #else
						  '';
						  #end
				return btn;
			}
		}
	]
});
/*课程-添加*/
function course_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url,
		end:function(){
			course_table.ajax.reload();
		}
	});
	layer.full(index);
}

/*课程-编辑*/
function course_edit(title,id){
	var index = layer.open({
		type: 2,
		title: "编辑课程",
		content: "#(baseUrl)/course/addPage?id="+id,
		end:function(){
			course_table.ajax.reload();
		}
	});
	layer.full(index);
}

/*课程-删除*/
function course_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '#(baseUrl)/course/remove',
			data: {"id":id},
			dataType: 'json',
			success: function(data){
				course_table.ajax.reload();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

/*课程-选课*/
function course_select(id){
	$.ajax({
		type: 'POST',
		url: '#(baseUrl)/sc/select',
		data: {"Course_ID":id},
		dataType: 'json',
		success: function(data){
			layer.msg('已成功选课!请在"选课详情"查看',{time:1000});
			course_table.ajax.reload();
		},
		error:function(data) {
			console.log(data.msg);
		},
	});	
}
</script>
#end